/*
 * @Author: Drc
 * @Date: 2021-05-12 18:01:33
 * @LastEditTime: 2021-06-07 12:01:08
 * @LastEditors: Drc
 */
import CryptoJS from 'crypto-js'

class AES {
  static iv = CryptoJS.enc.Utf8.parse('') //长度16 128位
  static cryptKey = CryptoJS.enc.Utf8.parse('') //长度32 256位
  static encrypt(msg: string) {
    let text = CryptoJS.AES.encrypt(msg, this.cryptKey, {iv: this.iv, mode: CryptoJS.mode.CBC})
    return text.toString()
  }

  static decrypt(msg: string) {
    return CryptoJS.AES.decrypt(msg, this.cryptKey, {iv: this.iv, mode: CryptoJS.mode.CBC}).toString(CryptoJS.enc.Utf8)
  }
}

export default class Crypto {
  static AES = AES
}
